package com.cm.common.core;

import lombok.AllArgsConstructor;
import lombok.Data;

/**
 * @类 名:Result </br>
 * @描 述:<br>
 * @日 期:2020/9/2 17:49 </br>
 * @作 者:小兰同学</br>
 * @版 本：1.0.0
 * @since JDK 1.8
 */

@Data
@AllArgsConstructor
public class Result<T> {
    static String SUCCESS_CODE = "0000";
    static String ERROR_CODE = "1111";
    private String code;
    private T data;
    private String msg = "ok";

    private Result() {
    }

    public static Result success() {
        return new Result<>(SUCCESS_CODE, true, "ok");
    }
    public static <T> Result success(T t) {
        return new Result<>(SUCCESS_CODE, t, "ok");
    }
    public static <T> Result success(T t,String msg) {
        return new Result<>(SUCCESS_CODE, t, msg);
    }
    public static Result fail() {
        return new Result<>(ERROR_CODE,false, "系统错误");
    }
    public static Result fail(String message) {
        return new Result<>(ERROR_CODE,false, message);
    }
    public static Result fail(String error,String message) {
        return new Result<>(error,false, message);
    }
}
